package 字符串类题目;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author zc
 * @version 1.0
 * @date 2021/9/1 10:29
 */
//数组与List之间的转化
public class Demo6 {
    public static void main(String[] args) {

        //方法一：
//        String[] array = {"123","abc","xyz","666"};
//        List<String> list = Arrays.asList(array);
//        System.out.println("数组转化为列表："+array);
//        for (int i = 0; i < list.size(); i++) {
//            System.out.print(list.get(i)+"  ");
//        }
//        }

        //方法二:
        String[] array = {"123","abc","xyz","666"};
        ArrayList<String> list = new ArrayList<>();
        System.out.println("数组转化为列表：");
        for (int i = 0; i < array.length ; i++) {
            list.add(array[i]);
            System.out.println(list.get(i)+" ");
        }
        System.out.println("\n列表长度为："+list.size());

        list.remove(3);
        System.out.println("移除索引为3的值后，列表为：");
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+"  ");
        }
        System.out.println("\n列表长度为："+list.size());
    }
}
